package com.example.userlogincenter.userCenter.util;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.Sign;
import cn.hutool.crypto.asymmetric.SignAlgorithm;
import cn.hutool.jwt.JWTUtil;

import java.util.HashMap;
import java.util.Map;

public class JWTUtils {


    /**
     *
     * 创建登录Token
     *
     * */
    public static String generateJWT(HashMap<String,Object> jwtMap,String phoneNumber){
        return JWTUtil.createToken(jwtMap, phoneNumber.getBytes());
    }


    /**
     *
     * 创建API签名
     *
     * */
    public static String generateApiSign(String keysalt){
        byte[] data = keysalt.getBytes();
        Sign sign = SecureUtil.sign(SignAlgorithm.MD5withRSA);
        byte[] signed = sign.sign(data);
        return new String(signed);
    }
}
